package cn.kzgg.ymcc.doc;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 针对于  Course 表的文档映射
 * indexName：索引库
 * type：类型(表类型)
 *
 * 在springboot中只需要打上相应的注解就能自动创建Es库映射创建表
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "course", type = "_doc")
public class CourseDoc {

    //对应文档的id  PUT  /index/type/id
    @Id
    private Long id;

    @Field(type = FieldType.Keyword)    //指定为 不分词
    private String gradeName;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String name;

    @Field(type= FieldType.Keyword)
    private String forUser;//使用人群

    @Field(type= FieldType.Long)
    private Long courseTypeId;//课程分类ID

    @Field(type= FieldType.Keyword)
    private String courseTypeName;//课程分类名

    @Field(type= FieldType.Keyword)
    private String pic;

    @Field(type= FieldType.Integer)
    private Integer totalMinute;

    @Field(type= FieldType.Date)
    private Date onlineTime;

    @Field(type= FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String teacherNames;

    @Field(type= FieldType.Keyword)
    private String chargeName;// 收费1免费，2收费

    @Field(type= FieldType.Double)
    private BigDecimal price;

    @Field(type= FieldType.Double)
    private BigDecimal priceOld;

    @Field(type= FieldType.Integer)
    private Integer saleCount;

    @Field(type= FieldType.Integer)
    private Integer viewCount;

    @Field(type= FieldType.Integer)
    private Integer commentCount;
}

